<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>万元加冕，现金等你赢！</title>
    <meta charset="utf-8">   
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="{$Think.config.static_path}apply/css/main.css">
    <link rel="stylesheet" type="text/css" href="{$Think.config.static_path}apply/css/common.css">
	<style type="text/css">
	#loading{
		text-align:center;
		position:fixed;
		top:45%;
		height:100%;
		left:50%;
	}

	</style>
</head>
<body class="layout">
	<div>
        <img src="{$Think.config.static_path}apply/images/logo.png" class="logo">
		<img src="{$Think.config.static_path}apply/images/top.png" class="top">
        <p class="tips">喜报来袭！江苏绿地会APP即将上线<br>面向会员征集APP名字，只要够创意你就来<br>万元大奖等您赢</p>
        <img src="{$Think.config.static_path}apply/images/line2.png" class="line2">
		<div class="form-choose">
			<div class="appname">
				<p>APP名称</p>
                <p><input type="text" placeholder="请输入2-5个汉字" maxlength="5" id="name"></p>
			</div>
			<div class="appcontent">
				<p>名称寓意</p>
                <p><textarea type="text" rows="5" cols="20" id="content" placeholder="输入名称阐释"></textarea></p>
			</div>
			<div class="btn" id="submit"><img src="{$Think.config.static_path}apply/images/submit.png"></div>
		</div>
		<p class="rule">
			<img src="{$Think.config.static_path}apply/images/rule.png">
		</p>
	</div>
</body>
<script charset="utf-8" type="text/javascript" src="{$Think.config.static_path}jquery-2.1.4.min.js"></script>
<script charset="utf-8" type="text/javascript" src="{$Think.config.static_path}apply/js/util.js"></script>
<script charset="utf-8" type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	weixinShare({$signPackage},{$sharePackage});
	var openid = "{$openid}";
	function weixinShare(configArr,shareArr){
		wx.config({
			 // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			debug: false,
			appId: configArr.appId,
			timestamp: configArr.timestamp, 
			nonceStr:  configArr.nonceStr,
			signature: configArr.signature,
			jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','showOptionMenu','chooseImage', 'uploadImage', 'downloadImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		});
		
		wx.ready(function () {
			wx.hideMenuItems({
				menuList: ['menuItem:originPage', 'menuItem:openWithQQBrowser', 'menuItem:share:qq', 'menuItem:openWithSafari', 'menuItem:share:email', 'menuItem:readMode', 'menuItem:refresh'] // 要隐藏的菜单项，所有menu项见附录3
			});
			wx.showOptionMenu();
			var shareData = {
					title:  shareArr.title,
					desc:    shareArr.desc,
					link:    shareArr.link,
					imgUrl:  shareArr.imgUrl,
					success:function(res){
					
						$.getJSON('__URL__/sharelog',{openid:openid,sharelink:shareArr.link}  ,function(json){	
							
						})
					}
				};
			
			wx.onMenuShareTimeline(shareData);
			wx.onMenuShareAppMessage(shareData);
		   
			// config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
		});
		wx.error(function (res) {
		
		});
	}
	$("#submit").click(function(){
		
		var name=$("#name").val();
		var content=$("#content").val();
		if(Util.isEmpty(name)){
			Util.info("请输入app名称");
			return;
		}
		if(name.length<2){
			Util.info("app名称必须为2-5个汉字");
			return;
		}
		if(!(/^[\u4e00-\u9fa5]+$/.test(name))){
			Util.info("app名称必须为2-5个汉字");
			return;
		}
		if(Util.isEmpty(content)){
			Util.info("请输入app含义");
			return;
		}
		
        Util.ajax({
			method:'post',
			data:'app_name='+name+'&app_info='+content+'&openid='+openid,
			url:'__URL__/ajaxInsert'},
			function(json) {
				if(json.status  == 2){
					 location.href = json.url;
					 return;
				}
				if(json.status  == 1){
					Util.info(json.info);
					setTimeout(function () {
						  location.href="__URL__/applyInfo?id="+json.id+"&showmsg=1";
					}, 3000);
				}else{
					Util.info(json.info);
				}
		});
		
	})

</script>
</html>